/*
 * GYAsyncCmdRegister.h
 *
 *  Created on: 2015年9月22日
 *      Author: gaoyi
 */

#ifndef GYASYNCCMDREGISTER_H_
#define GYASYNCCMDREGISTER_H_

class GYAsyncCmd;

/**
* 异步命令的工厂注册基类
*/
class GYAsyncCmdRegisterInf
{
public:
	GYAsyncCmdRegisterInf() { }
	virtual ~GYAsyncCmdRegisterInf() {}
public:
	virtual GYAsyncCmd* CreateObject() const = 0;
};

/**
* 异步命令的工厂注册类
*/
template<typename T>
class GYAsyncCmdRegister : public GYAsyncCmdRegisterInf
{
public:
	GYAsyncCmdRegister(int iCmdId);
	~GYAsyncCmdRegister();
public:
	virtual GYAsyncCmd*	CreateObject()	const;
};

// 简化注册的宏
#define GY_REGISTER_ASYNCCMD(CmdId, Class)	\
static const GYAsyncCmdRegister<Class> GYAsyncCmdRegister##Class(CmdId)

#endif /* GYASYNCCMDREGISTER_H_ */
